#include "insertionSort2.h"
#include<stdio.h>
#include<stdlib.h>
#include<time.h>

void insertionSort2(int a[], int length, float* tempo) {

     clock_t inicio, fim;
     inicio = clock();

     int i, j, value;
     for(i = 1; i < length; ++i) {
         value = a[i];
         for (j = i - 1; j >= 0 && a[j] > value; --j){             
             a[j + 1] = a[j]; 
             movimentarRegistro();
             a[j] = value; 
             movimentarRegistro();
         }
     }

     fim = clock();
     *tempo = ( (float)fim -(float)inicio ) / ( (float)CLOCKS_PER_SEC );
     printf("tempo insert2=%f\n", *tempo );
 }
